﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Besture.Bll;
using Besture.Common.Definition;
using Besture.Model;
using System.Data;

namespace Besture.UI.Education
{
    public partial class Finacedetail : System.Web.UI.Page
    {
        //Banner图
        public ImageModel _BannerTop { get; set; }
        public ActiveNewsClassModel _NewsClass { get; set; }
        public ActiveNewsModel _News { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["cid"] != null && !string.IsNullOrEmpty(Request.QueryString["cid"]))
                {
                    hidClassID.Value = Request.QueryString["cid"];
                    var modle = new ActiveNewsClassDac().GetModel(Convert.ToInt32(Request.QueryString["cid"]));
                    if (modle != null)
                        _NewsClass = modle;
                    else
                        _NewsClass = new ActiveNewsClassModel();
                }
                if (Request.QueryString["id"] != null && !string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    InitData(Convert.ToInt32(Request.QueryString["id"]));
                }
            }
            GetBanner();
        }

        #region 初始化数据
        private void InitData(int id)
        {
            ActiveNewsClassDac dac = new ActiveNewsClassDac();
            DataTable dt = dac.GetDataTable(Constants.DICTIONARY_Code_NewsClassEd);
            rbMeList.DataSource = dt;
            rbMeList.DataBind();

           var model= new ActiveNewsDac().GetModel(id);
           if (model != null)
               _News = model;
           else
               _News = new ActiveNewsModel();
        }
        #endregion

        #region 获取Banner
        /// <summary>
        /// 获取Banner
        /// </summary>
        public void GetBanner()
        {
            ImageDac imageDac = new ImageDac();
            ImageModel imgModel = imageDac.GetDataTableByCode(Constants.DICTIONARY_CODE_BannerEducation, Constants.DICTIONARY_TYPE_IMAGES);
            if (imgModel != null)
                _BannerTop = imgModel;
            else
                _BannerTop = new ImageModel();
        }
        #endregion
    }
}